/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : FileTypeSelect.c /Project:AVOS		       **
**        Revision : 1.1                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "FileTypeSelectEvent.h"
#include "./win/NetmenuSetupEvent.h"

INT32S WinFileTypeSelectMsgProc_720P(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return WinFileTypeSelectOnShow(hwnd, lpParam) ;
    }
    return 0 ;
}

void SetWinFileTypeSelectPalette_720P(void)
{
    YUVENTRY mask_para[4] = {0,0,0,4095};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | 16392,0x8000 | 21176,0x8000 | 17752,0x8000 | 16392,17592,19496,19832,19656,19992,18104,17673,17817,15864,15721,15912,16344};
    AWSetPalette(0,16, palette_para);
    return ;
}

void SetWinFileTypeSelectPos_720P(HWND* pControl, INT8U CurOsdSize)
{
    switch(CurOsdSize){
	case OsdSize720p:
	    RECT WindowRect720p = {0,0,1280,720};
	    pControl->winrect = WindowRect720p;
	    CREATEWINDOWPARAM WindowPara720p = {1,{{0,0,1280,720},    {0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_256,0,0,0},    SetWinFileTypeSelectPalette_720P};
	    AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&WindowPara720p);
	    break;
    }//end of switch
    return;
}

HWND *CreateControlWinFileTypeSelect_720P(HWND* pParent,INT8U CurOsdSize)
{
    HWND* pNewControl;
    switch(CurOsdSize){
	case OsdSize720p:
	     CREATEWINDOWPARAM window_para720p = {1,{{0,0,1280,720},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_256,0,0,0},SetWinFileTypeSelectPalette_720P};
            //Create Menu Window -- 1
            pNewControl = AWCreateWinControl("TWindow","WinFileTypeSelect_720P",WS_OVERLAPPEDWINDOW,
		                      0,0,1280,720,NULL, (INT32S)&window_para720p,WinFileTypeSelectMsgProc_720P) ;
            pNewControl->win_id = 0 ;
            break ;
    }//end of switch
            return pNewControl;
}

INT32S WinFileTypeSelectInfoMsgProc_720P(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return WinFileTypeSelectInfoOnShow(hwnd, lpParam) ;
        case WM_KEYDOWN:
            return WinFileTypeSelectInfoOnKeyPress(hwnd, lpParam) ;
    }
    return 0 ;
}
#ifdef TXT_PLAYER
void SetWinFileTypeSelectInfoPos_720P(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    switch(CurOsdSize){
	case OsdSize720p:
            pControl->winrect.top = pControl->parent->winrect.top + 0;
            pControl->winrect.left = pControl->parent->winrect.left + 0;
            pControl->winrect.width = 1280;
            pControl->winrect.height = 720;
            pControl->draw_info_num = 15;
            RECT DrawRect720p[15] = {
            {pControl->winrect.left + 165,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 365,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 565,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 765,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 965,pControl->winrect.top + 350,150,180},
             
            {pControl->winrect.left + 165,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 365,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 565,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 765,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 965,pControl->winrect.top + 560,132,36},
             
            {pControl->winrect.left + 211,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 411,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 611,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 811,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 1011,pControl->winrect.top + 484,132,36},
            };
            for(iLoop=0; iLoop < 15; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &DrawRect720p[iLoop], sizeof(RECT));
            break ;
    }//end of switch
    return;
}



HWND *CreateControlWinFileTypeSelectInfo_720P(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- WinFileTypeSelectInfo
    HWND *pNewControl;
    switch(CurOsdSize){
	case OsdSize720p:
            pNewControl = AWCreateWinControl("TControl","WinFileTypeSelectInfo_720P",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      0,0,1280,720,pParent,0,WinFileTypeSelectInfoMsgProc_720P) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 15;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO DrawDatas720p[15] = {
                          {0,0,0,0,(INT32U)ICON_MOVIE_FOCUS,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_MUSIC_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PHOTO_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_TXT_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_FILE_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA}};
            memcpy(pNewControl->draw_info,DrawDatas720p, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;
    }//end of switch
            return pNewControl;
}

#else
void SetWinFileTypeSelectInfoPos_720P(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
    switch(CurOsdSize){
	case OsdSize720p:
            pControl->winrect.top = pControl->parent->winrect.top + 0;
            pControl->winrect.left = pControl->parent->winrect.left + 0;
            pControl->winrect.width = 1280;
            pControl->winrect.height = 720;
            pControl->draw_info_num = 12;
            RECT DrawRect720p[12] = {
            {pControl->winrect.left + 284,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 484,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 684,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 884,pControl->winrect.top + 350,150,180},
            {pControl->winrect.left + 284,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 484,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 684,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 884,pControl->winrect.top + 560,132,36},
            {pControl->winrect.left + 330,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 530,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 730,pControl->winrect.top + 484,132,36},
            {pControl->winrect.left + 930,pControl->winrect.top + 484,132,36},
            };
            for(iLoop=0; iLoop < 12; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &DrawRect720p[iLoop], sizeof(RECT));
            break ;
    }//end of switch
    return;
}


HWND *CreateControlWinFileTypeSelectInfo_720P(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- WinFileTypeSelectInfo
    HWND *pNewControl;
    switch(CurOsdSize){
	case OsdSize720p:
            pNewControl = AWCreateWinControl("TControl","WinFileTypeSelectInfo_720P",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		                      0,0,1280,720,pParent,0,WinFileTypeSelectInfoMsgProc_720P) ;
            pNewControl->win_id = 1 ;
            pNewControl->draw_info_num = 12;
            pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            DRAWINFO DrawDatas720p[12] = {
                          {0,0,0,0,(INT32U)ICON_MOVIE_FOCUS,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_MUSIC_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_PHOTO_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)ICON_FILE_LOSE,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA},
                          {0,0,0,0,(INT32U)0,DT_RESOURCE_STRING_DATA}};
            memcpy(pNewControl->draw_info,DrawDatas720p, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            break ;
    }//end of switch
            return pNewControl;
}

#endif

HWND* CreateMenuWinFileTypeSelect_720P(void)
{
    HWND *pNewControl ;
    TWINDOWS *pWin;
    HWND *pWinFileTypeSelect = CreateControlWinFileTypeSelect_720P(NULL,CurrentOsdSize);
    SetWinFileTypeSelectPos_720P(pWinFileTypeSelect,CurrentOsdSize);

    pNewControl= CreateControlWinFileTypeSelectInfo_720P(pWinFileTypeSelect,CurrentOsdSize);
    SetWinFileTypeSelectInfoPos_720P(pNewControl,CurrentOsdSize);

    pWin = (TWINDOWS *)pWinFileTypeSelect;
    pWin->pFocusControl = AWFindWinCtrlByName("WinFileTypeSelectInfo_720P");
    return pWinFileTypeSelect;
}

void WinResetWinFileTypeSelectControlsPos_720P(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://WinFileTypeSelect
            SetWinFileTypeSelectPos_720P(pControl,CurOsdSize) ;
            break ;
        case 1://WinFileTypeSelectInfo
            SetWinFileTypeSelectInfoPos_720P(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}
void WinResetWinFileTypeSelectPos_720P(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("WinFileTypeSelect_720P");
    if(pControl == NULL) return ;

    WinResetWinFileTypeSelectControlsPos_720P(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWinFileTypeSelectPos_720P(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

